<template>
    <el-form
        :inline="true"
        :model="form"
        :rules="rules"
        ref="formRef"
    >

        <el-form-item prop="month">
            <el-date-picker
                v-model="form.month"
                type="month"
                placeholder="请选择月份"
                value-format="YYYY-MM-DD"
                clearable
            />
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit" :loading="subLoading">释放佣金</el-button>
        </el-form-item>

    </el-form>
</template>

<script lang="ts" setup>

import {reactive, ref} from "vue";
import {FormInstance} from "element-plus";
import {simplePost} from "@/utils/request";
import {msgSuccess} from "@/utils/alert";

    const rules = {
        month: [
            { required: true, message: '必须选择月份', trigger: 'blur' },
        ],
    }
    const formRef = ref<FormInstance>()
    const form = reactive({
        month:'',
    })
    const subLoading = ref<boolean>(false)

    const onSubmit = () => {
        formRef.value?.validate((valid, fields) => {
            if (valid){
                subLoading.value = true
                simplePost('/store.storeManager/freeDistReward', form).then(r => {
                    subLoading.value = false
                    msgSuccess("佣金释放成功")
                })
            }
        })
    }



</script>

<style scoped>

</style>
